package TreeMap;

import java.util.Set;
import java.util.TreeMap;

public class Test3 {
    public static void main(String[] args) {
        String str="aababcabcdabcde";
        TreeMap<Character,Integer> tm=new TreeMap<>();
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if(tm.containsKey(c)){
                Integer count = tm.get(c);
                count++;
                tm.put(c,count);
            }
            else{
                tm.put(c,1);
            }
        }

        Set<Character> ch = tm.keySet();
        for (Character c : ch) {
            Integer i = tm.get(c);
            System.out.print(c+" "+"("+i+")"+" ");
        }
    }
}

